log using log_gsem_FC2, replace

***** Replication code for Franchino, Fabio, and Camilla Mariotto. “Noncompliance Risk, Asymmetric Power and the Design of Enforcement of the European Economic Governance”. European Union Politics.

version 15
pause on
use conflict_data_FC2.dta, clear

***** Table 1: Governmental positions on national discretion and enforcement mechanisms
* Generalized structural equation model: Three-levels, Random intercepts
gsem (discr_com <- c.debt_gdp c.nbi c.nbi#c.debt_gdp i.eurozone i.crisis@0 i.cou_pres c.gov_lr c.gov_eu c.goodEU_net_6 i.comm_s M1[act] M2[act>issue_id], ologit ) ///
	 (discr_cou <- c.debt_gdp c.nbi c.nbi#c.debt_gdp i.eurozone i.crisis@0 i.cou_pres c.gov_lr c.gov_eu c.goodEU_net_6 i.comm_s M1[act] M2[act>issue_id], ologit ) ///
     (discr_nat <- c.debt_gdp                        i.eurozone i.crisis   i.cou_pres c.gov_lr c.gov_eu c.goodEU_net_6 i.comm_s M1[act] M2[act>issue_id], ologit ), vce(robust) nolog

pause /* type q to continue */

***** Table A2: Descriptive statistics
drop if e(sample)!=1 /* drop deleted observations */

summarize discr_nat discr_cou discr_com c.debt_gdp c.nbi i.eurozone i.crisis i.cou_pres c.gov_lr c.gov_eu c.goodEU_net_6 i.comm_s if e(sample)==1

pause /* type q to continue */

***** Substantive effects: National Discretion
** Effects of higher noncompliance risk (debt_gdp)
margins, atmeans
* probability of discr_nat = less , middle, more is 16%, 28%, 56% given that all predictors are set at their mean values.

margins, at(debt_gdp=9.974) atmeans
* probability of discr_nat = less , middle, more is 7%, 19%, 74% given that debt_gbp is at mean+s.d. and all other predictors are set at their mean values

* comparing of debt_gdp ratio for governments preferring less, middle or more discretion
sort discr_nat
by discr_nat : sum c.debt_gdp if e(sample)==1

* comparing of debt_gdp ratio for Germany and Italy
sort country
by country : sum c.debt_gdp discr_nat if e(sample)==1
* Germany
sum debt_gdp if e(sample)==1 & country==3
* Italy
sum debt_gdp if e(sample)==1 & country==4
sort issue_id
list country discr_nat issue_id if country==4 | country==3 | country==2

** Effects of eurozone membership
margins, dydx(eurozone)
* probability of discr_nat = less , middle, more is +12%, +4%, -16% for eurozone governments, all other predictors are set at their mean values

** Effects of Council presidency
margins, dydx(cou_pres)
* probability of discr_nat = less , middle, more is +11%, +1%, -13% for presidents, all other predictors are set at their mean values

** Effects of left-right shift
margins, at(gov_lr=4.134) atmeans
* probability of discr_nat = less , middle, more is 10%, 23%, 67% given that gov_lr is at mean-s.d. and all other predictors are set at their mean values

** Effects of anti-pro EU shift
margins, at(gov_eu=4.433) atmeans
* probability of discr_nat = less , middle, more is 22%, 32%, 47% given that gov_eu is at mean-s.d. and all other predictors are set at their mean values

** Effects of diffuse support (goodEU_net_6)
margins, at(goodEU_net_6=0.085) atmeans
* probability of discr_nat = less , middle, more is 19%, 31%, 50% given that gov_eu is at mean-s.d. and all other predictors are set at their mean values

pause /* type q to continue */

** A few scatter plots
graph twoway scatter gov_eu gov_lr			if e(sample)==1,  mlabel(id)  
graph twoway scatter goodEU_net_6 gov_lr 	if e(sample)==1,  mlabel(id)  
graph twoway scatter goodEU_net_6 gov_eu	if e(sample)==1,  mlabel(id)  
graph twoway scatter discr_nat gov_lr 		if e(sample)==1,  mlabel(id)  
graph twoway scatter discr_nat gov_eu 		if e(sample)==1,  mlabel(id)  mlabsize(tiny)  mlabposition(12) 
graph twoway scatter discr_nat goodEU_net_6 if e(sample)==1,  mlabel(id)  mlabsize(tiny)  mlabposition(12) 

pause /* type q to continue */

***** Council Enforcement
*** Figure 1: Marginal effect of noncompliance risk on preferring more Council involvement, over voting power
* Code from Thomas Brambor, William Roberts Clark, Matt Golder, Political Analysis 14: 63-82
matrix b=e(b)
matrix list b
scalar b17=b[1,17]
scalar b19=b[1,19]
sca dir
matrix V=e(V)
matrix list V
scalar varb17=V[17,17]
scalar varb19=V[19,19]
scalar covb17b19=V[17,19]
sca dir
generate MVZ=(_n+8)/10
replace  MVZ=. if _n>123
gen conbx=b17+b19*MVZ if _n<=123
gen consx=sqrt(varb17+varb19*(MVZ^2)+2*covb17b19*MVZ) if _n<=123
gen ax=1.96*consx
gen upperx=conbx+ax
gen lowerx=conbx-ax
gen where=-0.015 
gen pipe = "|" 
egen tag_nbi = tag(nbi)
gen yline=0
graph twoway hist nbi, width(0.5) percent color(gs14) yaxis(2) ///
		|| scatter where nbi if tag_nbi, plotr(m(b 4)) ms(none) mlabcolor(gs5) mlabel(pipe) mlabpos(6) legend(off)  ///
		||   line conbx   MVZ, clpattern(solid) clwidth(medium) clcolor(black) yaxis(1)  ///
        ||   line upperx  MVZ, clpattern(dash) clwidth(thin) clcolor(black)  ///
        ||   line lowerx  MVZ, clpattern(dash) clwidth(thin) clcolor(black)  ///
        ||   line yline  MVZ,  clwidth(thin) clcolor(black) clpattern(solid) || , ///
			 xlabel(1 5 10, noticks nogrid labsize(2)) xscale(noline) ylabel( 0 0.5 1 1.5, noticks axis(1) nogrid labsize(2))  ///
		     ylabel(0 5 10 15 20, noticks axis(2) nogrid labsize(2)) yscale(noline alt) yscale(noline alt axis(2)) legend(off) ///			 
			 title("" , size(2.5)) xtitle("Voting power (%)" , size(2.5)) ytitle("Marginal effect of {it:noncompliance risk}" , axis(1) size(2.5)) ytitle("" , axis(2) size(2.5)) ///
			 xsca(titlegap(2) r(0.3 1.5)) ysca(titlegap(2)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white)) saving(figure1, replace)

pause /* type q to continue */

* Descriptive statistics: noncompliance risk and positions on Council involvement in enforcement (large countries only)				 
sort discr_cou
by discr_cou: sum debt_gdp if e(sample)==1 & nbi>3.092

pause /* type q to continue */

***** Substantive effects: Council Enforcement
** Effects of interaction noncompliance risk (debt_gdp) x voting power (nbi)
margins, at(nbi=13.044) atmeans
* probability of discr_cou = less , middle, more is 9%, 45%, 45% given that nbi=13 (large voting power) all other predictors are set at their mean values.
margins, at(nbi=13.044 debt_gdp=9.974) atmeans
* probability of discr_cou = less , middle, more is 0.5%, 9%, 91% given that nbi=13 (large voting power) all other predictors are set at their mean values.
margins, at(nbi=0.942) atmeans
* probability of discr_cou = less , middle, more is 42%, 47%, 11% given that nbi=0.9 (small voting power) all other predictors are set at their mean values.
margins, at(nbi=0.942 debt_gdp=9.974) atmeans
* probability of discr_cou = less , middle, more is 45%, 45%, 9% given that nbi=0.9 (small voting power) all other predictors are set at their mean values.
** Effects of government left-right (gov_lr)
margins, atmeans
* probability of discr_cou = less , middle, more is 30%, 52%, 18% given all predictors are set at their mean values.
margins, at(gov_lr=7.298) atmeans
* probability of discr_cou = less , middle, more is 35%, 51%, 14% at an s.d. higher gov_lr and all other predictors are set at their mean values.
** Effects of eurozone
margins eurozone, atmeans
* probability of discr_cou = less , middle, more is 22%, 53%, 25% for non-eurozone governments
* probability of discr_cou = less , middle, more is 36%, 50%, 14% for eurozone governments

pause /* type q to continue */

***** Commission Enforcement
*** Figure A2: Marginal effect of noncompliance risk on preferring Commission involvement, over voting power
drop MVZ-yline
* Code from Thomas Brambor, William Roberts Clark, Matt Golder, Political Analysis 14: 63-82)
matrix b=e(b)
matrix V=e(V)
scalar b1=b[1,1]
scalar b3=b[1,3]
scalar varb1=V[1,1]
scalar varb3=V[3,3]
scalar covb1b3=V[1,3]
generate MVZ=(_n+8)/10
replace  MVZ=. if _n>123
gen conbx=b1+b3*MVZ if _n<=123
gen consx=sqrt(varb1+varb3*(MVZ^2)+2*covb1b3*MVZ) if _n<=123
gen ax=1.96*consx
gen upperx=conbx+ax
gen lowerx=conbx-ax
gen where=-0.16 
gen pipe = "|" 
egen tag_nbi = tag(nbi)
gen yline=0
graph twoway hist nbi, width(0.5) percent color(gs14) yaxis(2) ///
		|| scatter where nbi if tag_nbi, plotr(m(b 4)) ms(none) mlabcolor(gs5) mlabel(pipe) mlabpos(6) legend(off)  ///
		||   line conbx   MVZ, clpattern(solid) clwidth(medium) clcolor(black) yaxis(1)  ///
        ||   line upperx  MVZ, clpattern(dash) clwidth(thin) clcolor(black)  ///
        ||   line lowerx  MVZ, clpattern(dash) clwidth(thin) clcolor(black)  ///
        ||   line yline  MVZ,  clwidth(thin) clcolor(black) clpattern(solid) || , ///
			 xlabel(1 5 10, noticks nogrid labsize(2)) xscale(noline) ylabel(0 0.5 1, noticks axis(1) nogrid labsize(2))  ///
		     ylabel(0 5 10 15 20, noticks axis(2) nogrid labsize(2)) yscale(noline alt) yscale(noline alt axis(2)) legend(off) ///			 
			 title(" " , size(2.5)) xtitle("Voting power" , size(2.5)) ytitle("Marginal effect of {it:noncompliance risk}" , axis(1) size(2.5)) ytitle("" , axis(2) size(2.5)) ///
			 xsca(titlegap(2) r(0.3 1.5)) ysca(titlegap(2)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white)) saving(figureA2, replace)

pause /* type q to continue */
			 
** A few scatter plots and descriptive statistics
* issue = 1 (EDP methodological inspections)
* H3
graph twoway scatter discr_com nbi if e(sample)==1 & issue_id==1 & debt_gdp>6.523,  mlabel(country)  mlabsize(tiny) mlabpos(12) title(H3)
* high noncompliance risk countries, large voting power governments opposed the expansion of prerogatives; medium to small voting power governments supported it
graph twoway scatter discr_com nbi if e(sample)==1 & issue_id==1 & debt_gdp<6.523,  mlabel(country)  mlabsize(tiny) mlabpos(12)
* high noncompliance risk countries, large voting power governments opposed the expansion of prerogatives; medium to small voting power governments supported it
* H1
graph twoway scatter discr_com debt_gdp if e(sample)==1 & issue_id==1,  mlabel(country)  mlabsize(tiny) mlabpos(12) title(H1)

* issue = 5, 8, 13 (reverse QMV)
* H3
graph twoway scatter discr_com nbi if e(sample)==1 & (issue_id==5 | issue_id==8 | issue_id==13) & debt_gdp>6.523,  mlabel(country)  mlabsize(tiny) mlabpos(12) title(H3)
* H1
graph twoway scatter discr_com debt_gdp if e(sample)==1 & (issue_id==5 | issue_id==8 | issue_id==13),  mlabel(country)  mlabsize(tiny) mlabpos(12) title(H1)

* issue = 36 (reverse QMV)
* H3
graph twoway scatter discr_com nbi if e(sample)==1 & issue_id==36 & debt_gdp>6.523,  mlabel(country) msize(tiny) mlabsize(tiny) mlabpos(12) title(H3)
* H1
graph twoway scatter discr_com debt_gdp if e(sample)==1 & issue_id==36,  mlabel(country)  mlabsize(tiny) mlabpos(12) title(H1)
sort discr_com
by discr_com : sum c.debt_gdp if e(sample)==1 & issue_id==36

* issue = 39 (Commission and ECJ)
* H3
graph twoway scatter discr_com nbi if e(sample)==1 & issue_id==39 & debt_gdp>6.523,  mlabel(country) msize(tiny) mlabsize(tiny) mlabpos(12) title(H3)
* H1
graph twoway scatter discr_com debt_gdp if e(sample)==1 & issue_id==39,  mlabel(country) msize(tiny) mlabsize(tiny) mlabpos(12) title(H1)
sort discr_com
by discr_com : sum c.debt_gdp if e(sample)==1 & issue_id==39

* comparing of debt_gdp ratio for governments preferring less, middle or more discretion
sort discr_com
by discr_com : sum c.debt_gdp if e(sample)==1

pause /* type q to continue */

***** Substantive effects: Commission Enforcement
** Effects of diffuse support (goodEU_net_6)
margins, atmeans
* probability of discr_cou = less , middle, more is 58%, 0.8%, 41% - all predictors are set at their mean values.
margins, at(goodEU_net_6=0.085) atmeans
* probability of discr_cou = less , middle, more is 73%, 0.7%, 27% - all predictors are set at their mean values.

* diffuse support among high and low noncompliance risk countries
sort discr_com
by discr_com: sum goodEU_net_6 if debt_gdp>6.513137
by discr_com: sum goodEU_net_6 if debt_gdp<6.513137		  

log close
